﻿namespace HuaWei.CBR
{
    using DevExpress.XtraTab;
    using HuaWei;
    using HuaWei.CBR.QTJL;
    using HuaWei.CommClass;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmQTJL : Form
    {
        private IContainer icontainer = null;
        private XtraTabControl xtraTabControl1;
        private XtraTabPage xtraTabPage1;
        private XtraTabPage xtraTabPage2;
        private XtraTabPage xtraTabPage3;
        private XtraTabPage xtraTabPage4;
        private XtraTabPage xtraTabPage5;
        private XtraTabPage xtraTabPage6;
        private XtraTabPage xtraTabPage7;

        public FrmQTJL()
        {
            this.InitializeComponent();
            this.xtraTabPage3.PageVisible = GParams.DZYZ;
            this.xtraTabPage7.PageVisible = GParams.DZYZ;
        }

        protected override void DefWndProc(ref Message m)
        {
            this.method1(m.Msg);
            base.DefWndProc(ref m);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer != null))
            {
                this.icontainer.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmQTJL_FormClosed(object sender, FormClosedEventArgs e)
        {
        }

        private void FrmQTJL_FormClosing(object sender, FormClosingEventArgs e)
        {
            DevCCHelp.CloseTabControl(this.xtraTabControl1);
        }

        private void FrmQTJL_Load(object sender, EventArgs e)
        {
            if (this.xtraTabControl1.SelectedTabPageIndex != 0)
            {
                this.xtraTabControl1.SelectedTabPageIndex = 0;
            }
            else
            {
                this.method();
            }
        }

        private void InitializeComponent()
        {
            this.xtraTabControl1 = new XtraTabControl();
            this.xtraTabPage2 = new XtraTabPage();
            this.xtraTabPage7 = new XtraTabPage();
            this.xtraTabPage3 = new XtraTabPage();
            this.xtraTabPage5 = new XtraTabPage();
            this.xtraTabPage6 = new XtraTabPage();
            this.xtraTabPage1 = new XtraTabPage();
            this.xtraTabPage4 = new XtraTabPage();
            this.xtraTabControl1.BeginInit();
            this.xtraTabControl1.SuspendLayout();
            base.SuspendLayout();
            this.xtraTabControl1.Dock = DockStyle.Fill;
            this.xtraTabControl1.HeaderLocation = TabHeaderLocation.Left;
            this.xtraTabControl1.HeaderOrientation = TabOrientation.Horizontal;
            this.xtraTabControl1.Location = new Point(0, 0);
            this.xtraTabControl1.Name = "xtraTabControl1";
            this.xtraTabControl1.SelectedTabPage = this.xtraTabPage2;
            this.xtraTabControl1.Size = new Size(0x3da, 0x1eb);
            this.xtraTabControl1.TabIndex = 1;
            this.xtraTabControl1.TabPages.AddRange(new XtraTabPage[] { this.xtraTabPage7, this.xtraTabPage3, this.xtraTabPage5, this.xtraTabPage6, this.xtraTabPage1, this.xtraTabPage2, this.xtraTabPage4 });
            this.xtraTabControl1.SelectedPageChanged += new TabPageChangedEventHandler(this.xtraTabControl1_SelectedPageChanged);
            this.xtraTabControl1.SelectedPageChanging += new TabPageChangingEventHandler(this.xtraTabControl1_SelectedPageChanging);
            this.xtraTabControl1.SizeChanged += new EventHandler(this.xtraTabControl1_SizeChanged);
            this.xtraTabPage2.Name = "xtraTabPage2";
            this.xtraTabPage2.PageVisible = false;
            this.xtraTabPage2.Size = new Size(0x389, 0x1e4);
            this.xtraTabPage2.Text = "索赔金额";
            this.xtraTabPage7.Name = "xtraTabPage7";
            this.xtraTabPage7.Size = new Size(0x389, 0x1e4);
            this.xtraTabPage7.Text = "其它扣款";
            this.xtraTabPage3.Name = "xtraTabPage3";
            this.xtraTabPage3.Size = new Size(0x389, 0x1e4);
            this.xtraTabPage3.Text = "违约罚金";
            this.xtraTabPage5.Name = "xtraTabPage5";
            this.xtraTabPage5.Size = new Size(0x389, 0x1e4);
            this.xtraTabPage5.Text = "动员预付款";
            this.xtraTabPage6.Name = "xtraTabPage6";
            this.xtraTabPage6.PageVisible = false;
            this.xtraTabPage6.Size = new Size(0x389, 0x1e4);
            this.xtraTabPage6.Text = "材料预付款";
            this.xtraTabPage1.Name = "xtraTabPage1";
            this.xtraTabPage1.PageVisible = false;
            this.xtraTabPage1.Size = new Size(0x389, 0x1e4);
            this.xtraTabPage1.Text = "价格调整";
            this.xtraTabPage4.Name = "xtraTabPage4";
            this.xtraTabPage4.PageVisible = false;
            this.xtraTabPage4.Size = new Size(0x389, 0x1e4);
            this.xtraTabPage4.Text = "迟付款利息";
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.ClientSize = new Size(0x3da, 0x1eb);
            base.Controls.Add(this.xtraTabControl1);
            base.Name = "FrmQTJL";
            this.Text = "其它计量";
            base.FormClosing += new FormClosingEventHandler(this.FrmQTJL_FormClosing);
            base.FormClosed += new FormClosedEventHandler(this.FrmQTJL_FormClosed);
            base.Load += new EventHandler(this.FrmQTJL_Load);
            this.xtraTabControl1.EndInit();
            this.xtraTabControl1.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        private void method()
        {
            XtraTabPage selectedTabPage = this.xtraTabControl1.SelectedTabPage;
            if (selectedTabPage.Controls.Count == 0)
            {
                switch (this.xtraTabControl1.SelectedTabPageIndex)
                {
                    case 0:
                        if (!selectedTabPage.HasChildren)
                        {
                            FrmQTKK mqtkk = new FrmQTKK();
                            mqtkk.FormBorderStyle = FormBorderStyle.None;
                            mqtkk.TopLevel = false;
                            mqtkk.Width = selectedTabPage.Width;
                            mqtkk.Height = selectedTabPage.Height;
                            selectedTabPage.Controls.Add(mqtkk);
                            mqtkk.Show();
                        }
                        break;

                    case 1:
                        if (!selectedTabPage.HasChildren)
                        {
                            FrmWYFJ mwyfj = new FrmWYFJ();
                            mwyfj.FormBorderStyle = FormBorderStyle.None;
                            mwyfj.TopLevel = false;
                            mwyfj.Width = selectedTabPage.Width;
                            mwyfj.Height = selectedTabPage.Height;
                            selectedTabPage.Controls.Add(mwyfj);
                            mwyfj.Show();
                        }
                        break;

                    case 2:
                        if (!selectedTabPage.HasChildren)
                        {
                            FrmDYYFK_BZGS mdyyfk_bzgs = new FrmDYYFK_BZGS();
                            mdyyfk_bzgs.FormBorderStyle = FormBorderStyle.None;
                            mdyyfk_bzgs.TopLevel = false;
                            mdyyfk_bzgs.Width = selectedTabPage.Width;
                            mdyyfk_bzgs.Height = selectedTabPage.Height;
                            selectedTabPage.Controls.Add(mdyyfk_bzgs);
                            mdyyfk_bzgs.Show();
                        }
                        break;

                    case 3:
                        if (!selectedTabPage.HasChildren)
                        {
                            FrmCLYFK_GQKH mclyfk_gqkh = new FrmCLYFK_GQKH();
                            mclyfk_gqkh.FormBorderStyle = FormBorderStyle.None;
                            mclyfk_gqkh.TopLevel = false;
                            mclyfk_gqkh.Width = selectedTabPage.Width;
                            mclyfk_gqkh.Height = selectedTabPage.Height;
                            selectedTabPage.Controls.Add(mclyfk_gqkh);
                            mclyfk_gqkh.Show();
                        }
                        break;

                    case 4:
                        if (selectedTabPage.HasChildren)
                        {
                        }
                        break;

                    case 5:
                        if (selectedTabPage.HasChildren)
                        {
                        }
                        break;

                    case 6:
                        if (selectedTabPage.HasChildren)
                        {
                        }
                        break;
                }
            }
            else
            {
                this.method1(0x62);
            }
        }

        private void method1(int numD)
        {
            XtraTabPage selectedTabPage = this.xtraTabControl1.SelectedTabPage;
            if (selectedTabPage.Controls.Count > 0)
            {
                Form form = (Form) selectedTabPage.Controls[0];
                Win32API.SendMessage(form.Handle, numD, 0, 0);
            }
        }

        private void xtraTabControl1_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {
            this.method();
        }

        private void xtraTabControl1_SelectedPageChanging(object sender, TabPageChangingEventArgs e)
        {
            this.method1(0x61);
        }

        private void xtraTabControl1_SizeChanged(object sender, EventArgs e)
        {
            if (this.xtraTabControl1.SelectedTabPage.Controls.Count > 0)
            {
                Control control = this.xtraTabControl1.SelectedTabPage.Controls[0];
                if (control is Form)
                {
                    Form form = (Form) control;
                    form.Width = this.xtraTabControl1.SelectedTabPage.Width;
                    form.Height = this.xtraTabControl1.SelectedTabPage.Height;
                }
            }
        }
    }
}

